package net.sansi.v3correctserver.controller;

import com.dtflys.forest.annotation.Body;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sansi.v3correctserver.constenum.AppHelper;
import net.sansi.v3correctserver.dto.R;
import net.sansi.v3correctserver.dto.show.ShowDto;
import net.sansi.v3correctserver.dto.v3serverapi.V3ServerCorrectDto;
import net.sansi.v3correctserver.entity.screen.CorrectArea;
import net.sansi.v3correctserver.entity.space.CorrectCnf;
import net.sansi.v3correctserver.service.show.ShowService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * Created by Fang
 * create time : 2024/11/5
 * IDE : IntelliJ IDEA
 * <p>
 * 打屏接口
 */

@Api(tags = "打屏接口")
@RestController
@RequestMapping("/show")
@Validated
public class ShowController {

    @Resource
    private ShowService showService;

    @ApiOperation("查询是否支持硬件打屏")
    @GetMapping("/display/hardware/enable")
    public R<V3ServerCorrectDto.HardwarePreviewEnable> displayHardwareEnable(@RequestParam("screenId") @NotBlank String screenId) {
        return R.data(showService.hardwarePreviewEnable(screenId));
    }

    @ApiOperation("携带配置文件参数打屏")
    @PostMapping("/display/color")
    public R<Boolean> displayColor(@RequestBody @Validated ShowDto.DisplayReq req) {
        CorrectCnf correctCnf = AppHelper.projectSpace().getCorrectCnf();
        showService.show(correctCnf.getArea(req.getAreaId()), req.getBright(), req.getColorIdx(), req.getOfx(), req.getOfy());
        return R.data(true);
    }

    @ApiOperation("打黑屏")
    @PostMapping("/display/black")
    public R<Boolean> displayBlack() {
        showService.showBlack();
        return R.data(true);
    }

    @ApiOperation("关闭打屏")
    @PostMapping("/display/close")
    public R<Boolean> displayClose() {
        showService.closeDisplay();
        return R.data(true);
    }
}
